<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.AppName}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <p:layout fullPage="false" style="width: 99.9%;height: 99.9%;min-height: 600px; ">
                <p:layoutUnit position="west" size="330" style="height: 300px; " >
                    <h:panelGrid  columns="1" style="text-align: center; " >
                        <h:form id="form_menu">
                            <p:menu style="width: 300px; border-color: transparent">                               
                                <p:submenu label="#{bundle.SubjectSelectionTitle}">  
                                    <c:forEach var="subject" items="#{subjectBean.getAllSubjectsCurrentUser()}" >
                                        <p:menuitem value="#{subject.nombre}" action="#{subjectBean.selectSubject(subject)}" ajax="false" icon="ui-icon-note"/>  
                                    </c:forEach> 
                                </p:submenu>  
                            </p:menu> 
                        </h:form>
                    </h:panelGrid>
                </p:layoutUnit>
                <p:layoutUnit position="center" size="300" style="height: 300px; background: transparent;">
                    <h:form id="form">
                        <p:tabView id="tab" rendered="#{subjectBean.showTabContent()}" >
                            <p:tab title="Información" id="tabinfo">
                                <h:panelGrid columns="2">              
                                    <p:graphicImage value="resources/images/profiles/#{subjectBean.currentSubjectTeacher.fotoUrl}"  width="100px" height="100px" />
                                    
                                    <h:panelGrid columns="2" >
                                        <h:outputText value="Profesor: " styleClass="ui-label"/>
                                        <h:outputText value="#{subjectBean.currentSubjectTeacher.nombre}"/>
                                        <h:outputText value="Nombre Materia:" styleClass="ui-label"/>
                                        <h:outputText value="#{subjectBean.currentSubject.nombre}"/>
                                        <h:outputText value="Codigo Materia:" styleClass="ui-label"/>
                                        <h:outputText value="#{subjectBean.currentSubject.codMateria}"/>                                        
                                        <h:outputLabel value=""/>
                                        <p:editor value="#{subjectBean.currentSubject.descripcion}" rendered="#{subjectBean.validateTeacher()}"/>
                                        <h:outputLabel value=""/>   
                                        <p:commandButton value="Guardar" action="#{subjectBean.saveDescriptionSubject()}" ajax="false" update="tabinfo" rendered="#{subjectBean.validateTeacher()}"/>
                                    </h:panelGrid>
                                      <h:outputText value="Descripcion:" styleClass="ui-label"/>
                                     <h:outputText value="#{subjectBean.currentSubject.descripcion}" escape="false"/>
                                </h:panelGrid>
                            </p:tab >
                            <p:tab title="Alumnos">
                                <p:dataGrid var="user"  columns="3"  
                                            rows="12" paginator="true"  value="#{subjectBean.getStudentsfromSubject()}"
                                            currentPageReportTemplate="{startRecord} Pagina de {totalRecords}"
                                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                            rowsPerPageTemplate="9,12,15" >  

                                    <p:panel header="#{user.alias}" style="text-align:center">  
                                        <h:panelGrid columns="1" style="width:100%">  
                                            <p:graphicImage value="resources/images/profiles/#{user.fotoUrl}" width="120" height="120"/>  

                                            <h:outputText value="#{user.nombre}" />  
                                            <h:outputText value="#{user.descripcion}" />  
                                            <p:commandLink update=":form" oncomplete="carDialog.show()" title="View Detail">  
                                                <h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />   
                                                <f:setPropertyActionListener value="#{user}" target="#{subjectBean.currentSubjectStudent}" />  
                                            </p:commandLink>  
                                        </h:panelGrid>  
                                    </p:panel>  

                                </p:dataGrid>  
                            </p:tab>

                        </p:tabView>
                    </h:form>
                </p:layoutUnit>
            </p:layout>
        </ui:define>

    </ui:composition>

</html>

